{% extends "base.html" %}
{% block title %}打分{% endblock %}
{% block user %}{{ current_user.name }} {% endblock %}
{% block scripts %}{{ super() }}
<script>
    $(document).ready(function () {
        $('table').DataTable(
            {

                "autoWidth": false,
                "search": {
                    "regex": true
                },

                "pageLength": 25,
                // "order": [[2, "desc"], [0, "asc"]],

                dom: '<"top"flipB<"clear">>rt<"bottom"ipB<"clear">>',
                buttons: []


            });
    });
    $(function () {
        $('.grade').click(function () {
            var grade = parseInt($(this).siblings('input')[0].value);
            if (isNaN(grade) || grade <= 0 || grade > 100) {
                alert('请正确填写分数!(0-100)')
            }
            else {
                var user_id = $($(this).siblings('input')[0]).data("user-id");
                window.location.href = "{{ url_for('bp_assess.score_user',year=year, month=month, user_id=8888, grade=9999) }}".replace('8888', user_id).replace('9999', grade);
            }

        });
    });
    $(function () {
        $('.projectgrade').click(function () {
            var grade = parseInt($(this).siblings('input')[0].value);
            if (isNaN(grade) || grade <= 0 || grade > 100) {
                alert('请正确填写分数!(0-100)')
            }
            else {
                var user_id = $($(this).siblings('input')[0]).data("user-id");
                var project_id = $($(this).siblings('input')[0]).data("project-id");
                window.location.href = "{{ url_for('bp_assess.score_project_user',year=year, month=month, user_id=8888, grade=9999, project_id=7777) }}".replace('8888', user_id).replace('9999', grade).replace('7777', project_id);
            }

        });
    });
</script>
{% endblock %}
{% block content %}
<div class="container">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            {% include 'flash_message.html' %}
        </div>

        <!-- 部门考核 -->
        {% if org_children %}
        <h2 class="row page-header" style="text-align: center; color:crimson;">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <a class="btn btn-success" href="
                    {% if month== 1 %}
                        {{url_for('bp_assess.score_users',year=year-1,month=12)}}
                    {% else %}
                        {{url_for('bp_assess.score_users',year=year,month=month-1)}}
                    {% endif %}            
                    
                    ">上月</a>
                {{ year }} 年 {{ month }} 月 部门考核
                <a class="btn btn-success" href="              
                    
                    {% if month== 12 %}
                        {{url_for('bp_assess.score_users',year=year+1,month=1)}}
                    {% else %}
                        {{url_for('bp_assess.score_users',year=year,month=month+1)}}
                    {% endif %}        
                    ">下月</a>
            </div>
        </h2>

        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <!-- <table id="dt" class="row-border hover compact table" style="width:100%"> -->
            <table>
                <thead>
                    <tr>
                        <th>工号</th>
                        <th>姓名</th>
                        <th>组织</th>
                        <th>分数</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for user in org_children %}
                    <tr>
                        <td>{{ user[1] }}</td>
                        <td><a href="{{ url_for('bp_partner.calendar', user_id=user[0]) }}"> {{ user[2] }} </td>
                        <td>{{ user[3] }} </td>
                        <td>{{ user[4] }} </td>
                        <td>
                            <input type="text" data-user-id="{{ user[0] }}" style="width: 50px;">
                            {% if user[4] %}
                            <button class="grade">修改</button>
                            {% else %}
                            <button class="grade">打分</button>
                            {% endif %}

                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        {% endif %}


        <h2 class="row page-header" style="text-align: center;">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">

            </div>
        </h2>
        <!-- 项目考核 -->

        {% if project_user_list %}
        <h2 class="row page-header" style="text-align: center; color: blueviolet;">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <a class="btn btn-success" href="
                    {% if month== 1 %}
                        {{url_for('bp_assess.score_users',year=year-1,month=12)}}
                    {% else %}
                        {{url_for('bp_assess.score_users',year=year,month=month-1)}}
                    {% endif %}            
                    
                    ">上月</a>
                {{ year }} 年 {{ month }} 月 项目考核
                <a class="btn btn-success" href="              
                    
                    {% if month== 12 %}
                        {{url_for('bp_assess.score_users',year=year+1,month=1)}}
                    {% else %}
                        {{url_for('bp_assess.score_users',year=year,month=month+1)}}
                    {% endif %}        
                    ">下月</a>
            </div>
        </h2>

        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <table id="dt" class="row-border hover compact table" style="width:100%">
                <thead>
                    <tr>
                        <th>工作令号</th>
                        <th>项目名称</th>
                        <th>工号</th>
                        <th>姓名</th>
                        <th>分数</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for user in project_user_list %}
                    <tr>
                        <td>
                            <a href="{{ url_for('bp_assess.list_project_org', project_id=user[0]) }}">
                                {{ user[2] }}
                            </a>
                        </td>
                        <td>
                            <a href="{{ url_for('bp_assess.project_detail', project_id=user[0]) }}">
                                {{ user[3] }}
                            </a>
                        </td>
                        <td>{{ user[4] }}</td>
                        <td>
                            <a href="{{ url_for('bp_partner.calendar', user_id=user[1]) }}">

                                {{ user[5] }}
                            </a>



                        </td>
                        <td>{{ user[6] }}</td>
                        <td>

                            <input type="text" data-user-id="{{ user[1] }}" data-project-id="{{ user[0] }}"
                                style="width: 50px;">
                            {% if user[6] %}
                            <button class="projectgrade">修改</button>
                            {% else %}
                            <button class="projectgrade">打分</button>
                            {% endif %}


                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>

        {% endif %}

        <h2 class="row page-header" style="text-align: center;">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">

            </div>
        </h2>
        <!--  设计经理打分 -->

        {% if design_manager_list %}
        <h2 class="row page-header" style="text-align: center; color: coral;">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <a class="btn btn-success" href="
                    {% if month== 1 %}
                        {{url_for('bp_assess.score_users',year=year-1,month=12)}}
                    {% else %}
                        {{url_for('bp_assess.score_users',year=year,month=month-1)}}
                    {% endif %}            
                    
                    ">上月</a>
                {{ year }} 年 {{ month }} 月 设计经理考核
                <a class="btn btn-success" href="              
                    
                    {% if month== 12 %}
                        {{url_for('bp_assess.score_users',year=year+1,month=1)}}
                    {% else %}
                        {{url_for('bp_assess.score_users',year=year,month=month+1)}}
                    {% endif %}        
                    ">下月</a>
            </div>
        </h2>

        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <table id="dt" class="row-border hover compact table" style="width:100%">
                <thead>
                    <tr>
                        <th>工作令号</th>
                        <th>项目名称</th>
                        <th>工号</th>
                        <th>姓名</th>
                        <th>分数</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {% for user in design_manager_list %}
                    <tr>
                        <td>
                            <a href="{{ url_for('bp_assess.list_project_org', project_id=user[0]) }}">
                                {{ user[2] }}
                            </a>
                        </td>
                        <td>
                            <a href="{{ url_for('bp_assess.project_detail', project_id=user[0]) }}">
                                {{ user[3] }}
                            </a>
                        </td>
                        <td>{{ user[4] }}</td>
                        <td>{{ user[5] }}</td>
                        <td>{{ user[6] }}</td>
                        <td>

                            <input type="text" data-user-id="{{ user[1] }}" data-project-id="{{ user[0] }}"
                                style="width: 50px;">
                            {% if user[6] %}
                            <button class="projectgrade">修改</button>
                            {% else %}
                            <button class="projectgrade">打分</button>
                            {% endif %}


                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>

        {% endif %}


    </div>
</div>
{% endblock %}